package scjp.preparation.threads;

public class Thread2 implements Runnable {

	public boolean isRunnable = true;
	private int cnt = 0;
	/**
	 * @param args
	 */
	public static void main(String[] args) {

		Thread myThread = new Thread(new Thread2());
		myThread.setName("CounterThread");
		myThread.setName("SimpleThread");
		myThread.setPriority(9);
		myThread.start();
		
		try {
			myThread.join();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println(myThread.toString());
		System.out.println("In main method; thread name is: "
				+ Thread.currentThread().getName());

	}

	@Override
	public void run() {
		while(cnt < 10) {
			try {
				Thread.sleep(300);
				cnt++;
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			System.out.println("Count: " + cnt + " For Thread name: " + Thread.currentThread().getName());
		}

	}

}
